from datetime import datetime
from extensions import db

class ProfileSection_zc(db.Model):
    """个人主页版块模型"""
    __tablename__ = 'main_profile_section_zc'
    
    id = db.Column(db.Integer, primary_key=True)
    section_key = db.Column(db.String(50), unique=True, nullable=False)
    section_title = db.Column(db.String(100), nullable=False)
    section_content = db.Column(db.Text, nullable=False)
    cover_image_url = db.Column(db.String(256))
    sort_order = db.Column(db.Integer, default=0)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

class HeroImage_zc(db.Model):
    """首页轮播图模型"""
    __tablename__ = 'main_hero_image_zc'
    
    id = db.Column(db.Integer, primary_key=True)
    image_path = db.Column(db.String(256), nullable=False)
    image_title = db.Column(db.String(100))
    image_subtitle = db.Column(db.String(200))
    target_url = db.Column(db.String(256))
    display_sequence = db.Column(db.Integer, default=0)
    is_enabled = db.Column(db.Boolean, default=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)

class Post_zc(db.Model):
    """用户动态模型"""
    __tablename__ = 'main_post_zc'
    
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('auth_user_zc.id'), nullable=False)
    content = db.Column(db.Text, nullable=False)
    image_url = db.Column(db.String(256))
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
    
    # 关联关系
    user = db.relationship('User_zc', backref=db.backref('posts', lazy='dynamic')) 